import Vue from 'vue'
import App from './App.vue'
import router from './router'
//手动配置element-ui
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import store from './store.js'

Vue.use(ElementUI)

//导入全局样式
import './assets/css/global.css'
//导入字体图标
import './assets/font/iconfont.css'

import axios from 'axios'
//配置请求的根路径
axios.defaults.baseURL = 'http://localhost:3000/'
    // axios.interceptors.request.use(config => {
    //     //为请求头对象，添加token验证的Authorization字段
    //     config.headers.Authorization = window.sessionStorage.getItem('token')
    //     return config
    // })
Vue.prototype.$http = axios
Vue.config.productionTip = false
    //注册过滤器
Vue.filter('timeFilter', function(value) {
    // 返回处理后的值
    var minutes = Math.floor(value / 60000);
    var seconds = ((value % 60000) / 1000).toFixed(0);
    return (minutes < 10 ? '0' : '') + minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
})
Vue.filter('bofaCount', function(value) {
    if (value < 10000) return value
    else {
        return (value / 10000).toFixed(0) + '万'
    }
})

Vue.filter('dataForm', function(value) {
        var date = new Date(value);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        var d = date.getDate();
        return y + '-' + m + '-' + d
    })
    //为路由对象，添加beforeEach导航守卫
    // router.beforeEach((to, from, next) => {
    //     //从sessionStorage中获取到保存的token值
    //     const tokenStr = window.sessionStorage.getItem('token')
    // })
new Vue({
    store,
    router,
    render: h => h(App),

}).$mount('#app')